package com.zoe.onelink.doc.registry;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import springfox.documentation.spring.web.plugins.Docket;

@RequiredArgsConstructor
public class Knife4jDocketBeanPostProcessor implements BeanPostProcessor {


    private final DocketCustomConfigurator docketCustomConfigurator;

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof Docket) {
            Docket docket = (Docket) bean;
            if (docketCustomConfigurator != null) {
                docketCustomConfigurator.configure(docket);
            }
        }
        return bean;
    }
}
